import java.io.IOException;
import java.util.HashMap;
import java.util.Map;


public class ImageManager {
    private Map<String, String> imageMap = new HashMap<>();

    public void downloadImage(String url) throws IOException {
        String fileName = url.substring(url.lastIndexOf("/") + 1);
        String savePath = "images/" + fileName;
        FileUtils.saveImage(url, savePath);
        imageMap.put(fileName, savePath);
        FileUtils.appendLog("Downloaded: " + url + " -> " + savePath);
    }
    public void listImages(){
        imageMap.forEach((fileName,savePath) -> System.out.println(fileName+" -> "+savePath));
    }
    public String searchImages(String name){//name=filename
        return imageMap.get(name);
    }
}